﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PHPDecoder;
using System.IO;

namespace CodeVisual
{
    public partial class Output : UserControl
    {
        bool mousedown = false;
        string filename = null;
        public Output()
        {
            InitializeComponent();
        }

        public Output(String filename)
        {
            this.filename = filename;
            InitializeComponent();
            Random rnd = new Random();
            name.Text = Path.GetFileName(filename);
            this.Left = rnd.Next(586 - this.Width);
            this.Top = rnd.Next(355 - this.Height);
            ToolTip tt = new ToolTip();
            tt.SetToolTip(this, filename);
            tt.SetToolTip(name, filename);
            this.AutoSize = true;
        }

        public Output(String s, int posX, int posY)
        {
            InitializeComponent();
            name.Text = s;
            this.Left = posX;
            this.Top = posY;
        }

        
        private void Output_MouseDown(object sender, MouseEventArgs e)
        {
            this.BringToFront();
            mousedown = true;
            
        }

        private void Output_MouseUp(object sender, MouseEventArgs e)
        {
            mousedown = false;
        }

        private void Output_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //MessageBox.Show("OutPut");
            ViewNodeDialog d = new ViewNodeDialog(filename);
            d.ShowDialog();
            this.ShowOutput();
        }
        
        public void DrawControl(Control parent)
        {
            this.Parent = parent;
        }

        private void ShowOutput()
        {
        }

        private void Output_MouseMove(object sender, MouseEventArgs e)
        {
            if (mousedown)
            {
                this.Left += e.X;
                this.Top += e.Y;
            }
        }

        private void Output_MouseClick(object sender, MouseEventArgs e)
        {
            this.BringToFront();
        }

        private void name_Click(object sender, EventArgs e)
        {
            this.BringToFront();
        }
    }
}
